import 'package:flutter/material.dart';
import 'package:recipes/main/global/extension/int_extension.dart';

import '../data/data_supplier.dart';
import 'home_page_category_cell.dart';

class YSHHomePageContent extends StatelessWidget {
  const YSHHomePageContent({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return FutureBuilder(
        future: YSHHomePageDataSupplier.getHomePageCategoryData(),
        builder: (_, snapShot) {
          if (!snapShot.hasData) {
            return const Center(child: CircularProgressIndicator());
          }
          final modelList = snapShot.data;
          return GridView.builder(
              padding: const EdgeInsets.all(20.0),
              itemCount: modelList?.length,
              gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
                  crossAxisCount: 2,
                  crossAxisSpacing: 20.px,
                  mainAxisSpacing: 20.px,
                  childAspectRatio: 1.5),
              itemBuilder: (_, index) {
                return YSHHomePageCategoryCell(modelList![index]);
              });
        });
  }
}
